#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QString name, QWidget *parent):QMainWindow(parent),ui(new Ui::MainWindow)
{
    wind = new QList<GameWindow *>;
    Name = name;
    ui->setupUi(this);
    //ui->label_name->setText("Name: " + name);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_play_pressed()
{
    GameWindow *game = new GameWindow(true);
    (*wind) << game;
    game->show();
}

void MainWindow::on_pushButton_exit_pressed()
{
    this->close();
}

void MainWindow::closeEvent(QCloseEvent *event)
{
    QList<GameWindow *>::iterator it;
    for (it = wind->begin(); it!=wind->end(); ++it)
    {
        GameWindow *win;
        win = *it;
        win->close();
    }
}
